package com.service.imp;

import com.dao.InsertDao;
import com.pojo.Goods;
import com.pojo.Member;
import com.pojo.Provider;
import com.pojo.User;
import com.service.InsertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InsertServiceImp implements InsertService {
    @Autowired
    private InsertDao insertDao;
    public int insertUser(User user) {
        int i = insertDao.insertUserCount(user);
        if (i<=0){
            return insertDao.insertUser(user);
        }
        return -1;
    }

    public int insertProvider(Provider provider) {
        int i = insertDao.insertProviderCount(provider);
        if (i<=0){
            return insertDao.insertProvider(provider);
        }
        return -1;
    }

    public List<Provider> getProviderToGoods() {
        return insertDao.getProviderToGoods();
    }

    public int insertGoods(Goods goods) {
        int i = insertDao.insertGoodsCount(goods);
        if (i<=0){
            return insertDao.insertGoods(goods);
        }
        return -1;
    }

    public int insertMember(Member member) {
        int i = insertDao.insertMemberCount(member);
        if (i<=0){
            return insertDao.insertMember(member);
        }
        return -1;

    }
}
